package com.qf.blog.controller.web;

import com.qf.blog.core.servlet.BaseServlet;
import com.qf.blog.entity.InvitataionEntity;
import com.qf.blog.service.IInvitataionService;
import com.qf.blog.service.impl.InvitataionServiceImpl;
import com.qf.blog.vo.IndexDataVo;
import org.omg.IOP.ExceptionDetailMessage;
import org.springframework.context.ApplicationContext;

import javax.servlet.annotation.WebServlet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@WebServlet("/IndexServlet/*")
public class IndexServlet extends BaseServlet {

    private IInvitataionService invitataionService;

    @Override
    public void myInit() {
        ApplicationContext ctx = (ApplicationContext)this.req.getServletContext().getAttribute("spring");
        invitataionService = ctx.getBean(IInvitataionService.class);
    }

    public void index() throws Exception {
        // 1.获取数据
        List<IndexDataVo> list = invitataionService.indexDataList();

        // 2.放到Map中
        Map<String, Object> map = new HashMap<>();
        map.put("indexDataVoList", list);

        // 3.跳转到视图
        outView("view/index", map); // 威
    }
}
